package com.zeng.config;

import com.zeng.bean.Person;
import com.zeng.filter.MyTypeFilter;
import com.zeng.service.BookService;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

/**
 * @author Zqm
 * @Title: MainConfig
 * @ProjectName SpringAnnotationDriven
 * @date 2019/1/10
 * 配置类 等于之前的配置文件
 */

@Configuration
@ComponentScan(value = "com.zeng"
//        ,excludeFilters = {
//                @ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class, Service.class})  //排除controller service注解  指定排除规则
//        }
        ,includeFilters = {
            /*@ComponentScan.Filter(type = FilterType.ANNOTATION,classes = {Controller.class})
            ,@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes = {BookService.class})
            ,*/@ComponentScan.Filter(type = FilterType.CUSTOM,classes = {MyTypeFilter.class})
        },
        useDefaultFilters = false  //关闭默认扫描 includeFilters才能执行
)

//@ComponentScans(value = {
//
//})   和上面达到同样的效果
public class MainConfig {

    @Bean("person1")
    public Person person(){
        return new Person("张三",20,"小张三");
    }
}
